﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BLL;
using DAL;
using System.Text;
using System.Data;
using System.Xml;

public partial class cn_advanced_search : System.Web.UI.Page
{
    // Fields
    protected BrandManager bm = new BrandManager();
    protected CategoryManager cm = new CategoryManager();


    // Methods
    protected StringBuilder BrandBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataTable brandByLanguage = this.bm.GetBrandByLanguage("zh-CN");
            foreach (DataRow row in brandByLanguage.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<option value=\"", row["id"], "\">", row["brandName"], "</option>" }));
            }
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder CategoryBind()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            this.RecursionCategory(sb, "00000000-0000-0000-0000-000000000000", "zh-CN");
        }
        catch
        {
        }
        return sb;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    private void RecursionCategory(StringBuilder sb, string parentCategory, string languageVersion)
    {
        DataTable table = this.cm.GetCategoryByParentIdAndLanguageVersionAndIsShow(parentCategory, languageVersion, 1);
        if (table.Rows.Count > 0)
        {
            foreach (DataRow row in table.Rows)
            {
                string str = "";
                int num = Convert.ToInt32(row["depth"]);
                if (num > 0)
                {
                    for (int i = 0; i < num; i++)
                    {
                        str = str + "&nbsp;&nbsp;&nbsp;&nbsp;";
                    }
                    str = str + "┣";
                }
                sb.AppendLine("<option value=\"" + row["categoryIdentity"].ToString() + "\">" + str + row["categoryName"].ToString() + "</option>");
                this.RecursionCategory(sb, row["id"].ToString(), languageVersion);
            }
        }
    }

}